import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { EntityHelper } from '../../utils/entity-helper';
import { Permission } from '../../permission/entities/permission.entity';
import { Role } from '../../role/entities/role.entity';

@Entity('role_permission')
export class RolePermission extends EntityHelper {
	@PrimaryGeneratedColumn()
	id: number;

	@Column({ name: 'role_id' })
	roleId: number;

	@Column({ name: 'permission_id' })
	permissionId: number;

	@ManyToOne((type) => Permission, (permission) => permission.id)
	@JoinColumn({ name: 'permission_id' })
	permission: Permission;

	@ManyToOne((type) => Role, (role) => role.id)
	@JoinColumn({ name: 'role_id' })
	role: Role;
}
